integer door_num=922; //change this to be whatever door number the adjacent door has

//- - - - - - - - - - - - - - - -     
integer open() // Opens the door.
{
    // vv  Replace this snippet with custom code to close the door vv 
    rotation rot = llGetLocalRot();
    rotation delta = llEuler2Rot(<0,0,-PI/4>);
    rot = delta * rot;
    llSetLocalRot(rot);
    llSleep(0.25);
    rot = delta * rot;
    llSetLocalRot(rot);
    // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
    return TRUE;
}
//- - - - - - - - - - - - - - - -     
integer close() // Closes the door.
{
    // vv  Replace this snippet with custom code to close the door vv
    rotation rot = llGetLocalRot();
    rotation delta = llEuler2Rot(<0,0,PI/4>);
    rot = delta * rot;
    llSetLocalRot(rot);
    llSleep(0.25);
    rot = delta * rot;
    llSetLocalRot(rot);
    // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
    return FALSE;
}
//- - - - - - - - - - - - - - - -     

default
{
    state_entry()
    {
    }

    touch_start(integer total_number)
    {
        llMessageLinked(LINK_SET, door_num, "Touched", llDetectedName(0));
    }
    
    link_message(integer sender_num, integer num, string str, key id)
    {
        if (num==door_num)
        {
            if (str=="Open")
            {
                open();
            }
            if (str=="Close")
            {
                close();
            }
        }
    }
}
